package com.heima.search.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.search.dtos.HistorySearchDto;
import com.heima.search.pojos.ApUserSearch;
import com.heima.search.service.HistoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author brianxia
 * @version 1.0
 * @date 2022-10-30 10:09
 */
@RestController
@RequestMapping("/api/v1/history")
public class HistoryController {

    @Autowired
    private HistoryService historyService;

    @PostMapping("/load")
    public ResponseResult load(){
        List<ApUserSearch> list = historyService.load();
        return ResponseResult.okResult(list);
    }

    @PostMapping("/del")
    public ResponseResult del(@RequestBody HistorySearchDto dto){
        historyService.del(dto);
        return ResponseResult.okResult(null);
    }
}
